Repository navigation
test(spanner): unflake java8-samples - #14938
sakthivelmanii wants to merge 1 commit into
Conversation
…r/nightly/java8-samples Fix ClassCastException by correctly wrapping GAX exceptions using SpannerExceptionFactory.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates several database administration methods in PgSpannerSample.java to safely handle ExecutionException. Instead of directly casting e.getCause() to SpannerException, which could lead to a ClassCastException if the cause is of a different type, the code now utilizes SpannerExceptionFactory.asSpannerException(e.getCause()) to perform a safe conversion. There are no review comments, so I have no additional feedback to provide.
There was a problem hiding this comment.
Code Review
This pull request updates PgSpannerSample.java to replace direct casting of e.getCause() to SpannerException with SpannerExceptionFactory.asSpannerException(e.getCause()) across multiple database administration methods. This prevents potential ClassCastException issues if the cause of the ExecutionException is not a SpannerException. There are no review comments to address, and I have no additional feedback to provide.
Problem
PgSpannerSample.javacode catches anExecutionExceptionand attempts to cast its cause directly to aSpannerException.com.google.api.gax.rpc.FailedPreconditionException, resulting in aClassCastException.java8-samplestest to fail.Solution
SpannerExceptionFactory.asSpannerException(e.getCause())to correctly convert or wrap the GAX exception into aSpannerExceptioninstead of casting directly.